Skip to content

test: extend BenchmarkScheduling with multi-NodePool variants - #3246

Draft
nathangeology wants to merge 1 commit into
kubernetes-sigs:mainfrom
nathangeology:bench/scheduling-multi-nodepool
Draft

test: extend BenchmarkScheduling with multi-NodePool variants#3246
nathangeology wants to merge 1 commit into
kubernetes-sigs:mainfrom
nathangeology:bench/scheduling-multi-nodepool

Conversation

@nathangeology

Copy link
Copy Markdown
Contributor

Fixes #N/A

Description

Adds BenchmarkSchedulingMultiNodePool to pkg/controllers/provisioning/scheduling/scheduling_benchmark_test.go. The existing BenchmarkScheduling* family drives Scheduler.Solve against a single NodePool, so per-NodePool costs never appear in the numbers. The new sub-benchmarks cover a (NodePoolCount, PodCount) grid of {5, 10, 20} x {100, 500, 1000} NodePools by pods, giving nine cells.

Cross-NodePool cost lives in a few paths that the single-NodePool benches skip: NewTopology -> buildDomainGroups iterates NodePools when constructing domain groups, per-NodePool GetInstanceTypes fans out during scheduling, and per-NodePool scheduling-template construction runs once per NodePool. A regression in any of those paths lands on the row of the grid that exercises it, so ns/op, B/op, and allocs/op deltas point at the offending path rather than getting averaged into a single number.

A helper setupMultiNodePoolScheduler constructs the fixture: nodePoolCount NodePools with generous CPU and memory limits, sharing the same 100-instance-type list from fake.InstanceTypes(100). Scheduler.Solve runs against makeDiversePods(podCount). No new dependencies. No changes to production code.

How was this change tested?

Ran the new benchmark family locally with a single iteration per sub-bench to confirm every cell executes and reports timings:

go test -tags=test_performance -bench=BenchmarkSchedulingMultiNodePool -benchtime=1x -run=^$ ./pkg/controllers/provisioning/scheduling/...
goos: darwin
goarch: arm64
pkg: sigs.k8s.io/karpenter/pkg/controllers/provisioning/scheduling
cpu: Apple M4 Pro
BenchmarkSchedulingMultiNodePool/5NP_100Pods-14           1      777765375 ns/op
BenchmarkSchedulingMultiNodePool/5NP_500Pods-14           1     5859031625 ns/op
BenchmarkSchedulingMultiNodePool/5NP_1000Pods-14          1     9188544375 ns/op
BenchmarkSchedulingMultiNodePool/10NP_100Pods-14          1      738149500 ns/op
BenchmarkSchedulingMultiNodePool/10NP_500Pods-14          1     3523763250 ns/op
BenchmarkSchedulingMultiNodePool/10NP_1000Pods-14         1     7514327959 ns/op
BenchmarkSchedulingMultiNodePool/20NP_100Pods-14          1      614226125 ns/op
BenchmarkSchedulingMultiNodePool/20NP_500Pods-14          1     4771892084 ns/op
BenchmarkSchedulingMultiNodePool/20NP_1000Pods-14         1     9333993542 ns/op
PASS
ok      sigs.k8s.io/karpenter/pkg/controllers/provisioning/scheduling   49.377s

make verify, make vulncheck, and make licenses all pass locally on the rebased branch. Numbers above are with -benchtime=1x for a smoke-test only; longer runs are needed before treating any single cell as a baseline.

AI Disclosure

I used an LLM to parallel program with me on this. That included drafting the PR description and running the rebase against upstream/main. All code changes on this branch were authored by me previously; the LLM did not write the benchmark code.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add BenchmarkSchedulingMultiNodePool exercising Scheduler.Solve over
fixtures with 5, 10, and 20 NodePools across pod counts of 100, 500, and
1000. The existing BenchmarkScheduling* family runs against a single
NodePool, which hides cross-NodePool cost in NewTopology
(buildDomainGroups), per-NodePool GetInstanceTypes fan-out, and
per-NodePool scheduling-template construction. The new sub-benches
report ns/op, B/op, and allocs/op across the (NodePoolCount, PodCount)
grid so that a regression in any of those paths surfaces on the
appropriate cell.

Refs kubernetes-sigs#2997

Signed-off-by: Nathaniel Jones <jonesflp@amazon.com>
@kubernetes-prow kubernetes-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 18, 2026
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nathangeology
Once this PR has been reviewed and has the lgtm label, please assign derekfrank for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 18, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from mwielgus and tallaxes August 18, 2026 19:57
@kubernetes-prow kubernetes-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant